﻿using BLL.Sys;
using DEL.Sys;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Authentication;
using Microsoft.AspNetCore.Mvc;
using NLog;
using System;
using System.Security.Claims;
using System.Threading.Tasks;
using Web.Models;

namespace Web.Areas.Sys.Controllers
{
    [Area("Sys")]
    [Authorize]
    public class HomeController:Controller
    {
        //定义一记录日志的容器
        protected static Logger Logger = LogManager.GetCurrentClassLogger();

        [AllowAnonymous]
        public IActionResult Index()
        {
            return View();
        }

        public IActionResult About()
        {
            ViewData["Message"] = "Your application description page.";

            return View();
        }

        public IActionResult Error()
        {
            return View();
        }
               

        //权限不足时跳转
        public IActionResult AccessDenied()
        {
            return View();
        }

        

        public async Task<IActionResult> Logout()
        {
            //退出当前用户的登录，删除登录的cookie信息
            await HttpContext.Authentication.SignOutAsync("MyCookieMiddlewareInstance");
            //HttpContext.Session.Clear();
            return RedirectToAction("/");
        }
    }
}
